{% extends 'configmanager/__base__.html' %}
{% block title %}发布申请列表 | {% endblock %}
{% block search_notice %}请输入 发布编号{% endblock %}
{% block content %}
{% load systemmanager %}

<div id="whole" class="container-fluid table-responsive">
    {% if apply_list %}
    <table class="table table-striped table-hover table-condensed">
        <th>申请编号</th>
        <th>状态</th>
        <th>申请人</th>
        <th>申请时间</th>
        <th>期望发布时间</th>
        <th>发布人</th>
        <th>实际发布时间</th>
        <th class="text-center">操作</th>
        {% for apply in apply_list %}
        <tr>
            <td>
                <a href="{% url 'configmanager:applychange' apply.id %}">{{ apply.applyproject }}</a>
            </td>
            <td>
                {% if apply.status == "WC" %}
                <span>待提交</span>
                {% elif apply.status == "WD" %}
                <span>待发布</span>
                {% elif apply.status == "C" %}
                <span>已取消</span>
                {% elif apply.status == "D" %}
                <span>已发布</span>
                {% elif apply.status == "DA" %}
                <span>研发经理审批中</span>
                {% elif apply.status == "OA" %}
                <span>运维经理审批中</span>
                {% elif apply.status == "EA" %}
                <span>运维工程师审批中</span>
                {% elif apply.status == "TA" %}
                <span>测试经理审批中</span>
                {% elif apply.status == "TDA" %}
                <span>技术总监审批中</span>
                {% endif %}
            </td>
            <td>
                {{ apply.apply_user }}
            </td>
            <td>
                {{ apply.apply_time }}
            </td>
            <td>
                {% if apply.wishdeploy_time is null %}
                {% else %}
                {{ apply.wishdeploy_time }}
                {% endif %}
            </td>
            <td>
                {% if apply.deploy_user is null %}
                {% else %}
                {{ apply.deploy_user }}
                {% endif %}
            </td>
            <td>
                {% if apply.deploy_time is null %}
                {% else %}
                {{ apply.deploy_time }}
                {% endif %}
            </td>
            <td class="text-right">
                <!--修改按钮-->
                {% if apply.status == "WC" %}
                <a class="btn btn-success" href="{% url 'configmanager:applychange' apply.id %}">修改</a>
                {% endif %}
                <!--审核按钮-->
                {% if apply.status == "DA" %}
                {% if request.user.is_superuser or request.user|has_group:"admin" or request.user|has_group:"研发经理" %}
                <a class="btn btn-primary" href="{% url 'configmanager:applychange' apply.id %}">研发经理审核</a>
                {% endif %}
                {% endif %}
                {% if apply.status == "TA" %}
                {% if request.user.is_superuser or request.user|has_group:"admin" or request.user|has_group:"测试经理" %}
                <a class="btn btn-primary" href="{% url 'configmanager:applychange' apply.id %}">测试经理审核</a>
                {% endif %}
                {% endif %}
                {% if apply.status == "EA" %}
                {% if request.user.is_superuser or request.user|has_group:"admin" or request.user|has_group:"运维工程师" %}
                <a class="btn btn-primary" href="{% url 'configmanager:applychange' apply.id %}">运维工程师审核</a>
                {% endif %}
                {% endif %}
                {% if apply.status == "OA" %}
                {% if request.user.is_superuser or request.user|has_group:"admin" or request.user|has_group:"运维经理" %}
                <a class="btn btn-primary" href="{% url 'configmanager:applychange' apply.id %}">运维经理审核</a>
                {% endif %}
                {% endif %}
                {% if apply.status == "TDA" %}
                {% if request.user.is_superuser or request.user|has_group:"admin" or request.user|has_group:"技术总监" %}
                <a class="btn btn-primary" href="{% url 'configmanager:applychange' apply.id %}">技术总监审核</a>
                {% endif %}
                {% endif %}
                <!--现在去发布按钮-->
                {% if request.user.is_superuser or request.user|has_group:"运维工程师" or request.user|has_group:"admin" %}
                {% if apply.status == 'WD' %}
                <a class="btn btn-info" href="{% url 'configmanager:deploysitelist' apply.id %}">现在去发布</a>
                {% endif %}
                {% endif %}
                <!--删除按钮-->
                {% if request.user.is_superuser or request.user|has_group:"admin"%}
                <a class="btn btn-danger" href="{% url 'configmanager:applydelete' apply.id %}"
                   onclick="return confirm('Are you sure you want to delete this?')">删除</a>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
    </table>
    {% else %}
    <p>No apply are available.</p>
    {% endif %}

</div>
{% endblock %}
